package com.zlcx.tz.live.common.wrapper;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.stereotype.Component;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * <p></p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 *
 * @author zl
 * @version 1.0
 * @date Created in 2019/5/17 13:17
 * @copyright: Copyright (c) founders
 */
@Slf4j
@Component
@ServletComponentScan
@WebFilter(urlPatterns = "/*", filterName = "translateRequestWrapper")
public class TranslateRequestWrapper implements Filter {


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        ServletRequest requestWrapepr = new RequestBodyCachingWrapper((HttpServletRequest) servletRequest);
        filterChain.doFilter(requestWrapepr, servletResponse);
    }

    @Override
    public void destroy() {

    }
}
